#include "widget.h"
#include "ui_widget.h"
#include <QDebug>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    button1 = new QPushButton("修改窗口名称",this);

    button1->move(20,20);

    button2 = new QPushButton("切换槽函数",this);
    button2->move(20,60);

    connect(button1,&QPushButton::clicked,this,&Widget::handleClick);

    connect(button2,&QPushButton::clicked,this,&Widget::Swap);
}

void Widget::handleClick()
{
    this->setWindowTitle("修改窗口名称");

    qDebug() << "Handler1" ;
}

void Widget::handleClick2()
{
    this->setWindowTitle("修改窗口名称2");

    qDebug() << "Handler2" ;
}

Widget::~Widget()
{
    delete ui;
}

void Widget::Swap()
{
    disconnect(button1,&QPushButton::clicked,this,&Widget::handleClick);

    connect(button1,&QPushButton::clicked,this,&Widget::handleClick2);
}

void Widget::on_pushButton_clicked()
{

}

